import {
  getRoleList,
  changeRoleStatus,
  getb4Button,
  saveb4Button,
  getMenuqx,
  saveMenuqx,
  editRole,
  addRole,
  deleteRole
} from '@/api/role'

export default {
  state: {
  },
  mutations: {

  },
  getters: {},
  actions: {
    handleGetRoleList ({ state, commit }, data) {
      return new Promise((resolve, reject) => {
        getRoleList(data)
          .then(res => {
            resolve(res)
          })
          .catch(err => {
            reject(err)
          })
      })
    },

    // 修改角色状态
    handleChangeRoleStatus ({ state, commit }, data) {
      return new Promise((resolve, reject) => {
        changeRoleStatus(data)
          .then(res => {
            resolve(res)
          })
          .catch(err => {
            reject(err)
          })
      })
    },

    handleGetb4Button ({ state, commit }, data) {
      return new Promise((resolve, reject) => {
        getb4Button(data)
          .then(res => {
            resolve(res)
          })
          .catch(err => {
            reject(err)
          })
      })
    },

    handleSaveb4Button ({ state, commit }, data) {
      return new Promise((resolve, reject) => {
        saveb4Button(data)
          .then(res => {
            resolve(res)
          })
          .catch(err => {
            reject(err)
          })
      })
    },

    handleGetMenuqx ({ state, commit }, data) {
      return new Promise((resolve, reject) => {
        getMenuqx(data)
          .then(res => {
            resolve(res)
          })
          .catch(err => {
            reject(err)
          })
      })
    },

    handleSaveMenuqx ({ state, commit }, data) {
      return new Promise((resolve, reject) => {
        saveMenuqx(data)
          .then(res => {
            resolve(res)
          })
          .catch(err => {
            reject(err)
          })
      })
    },

    handleEditRole ({ state, commit }, data) {
      return new Promise((resolve, reject) => {
        editRole(data)
          .then(res => {
            resolve(res)
          })
          .catch(err => {
            reject(err)
          })
      })
    },

    handleAddRole ({ state, commit }, data) {
      return new Promise((resolve, reject) => {
        addRole(data)
          .then(res => {
            resolve(res)
          })
          .catch(err => {
            reject(err)
          })
      })
    },

    handleDeleteRole ({ state, commit }, data) {
      return new Promise((resolve, reject) => {
        deleteRole(data)
          .then(res => {
            resolve(res)
          })
          .catch(err => {
            reject(err)
          })
      })
    }
  }
}
